import 'package:yurun_smartmerchants/models/batch_entity.dart';

batchEntityFromJson(BatchEntity data, Map<String, dynamic> json) {
	if (json['last'] != null) {
		data.last = json['last'];
	}
	if (json['totalPage'] != null) {
		data.totalPage = json['totalPage']?.toInt();
	}
	if (json['content'] != null) {
		data.content = new List<BatchContent>();
		(json['content'] as List).forEach((v) {
			data.content.add(new BatchContent().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> batchEntityToJson(BatchEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['last'] = entity.last;
	data['totalPage'] = entity.totalPage;
	if (entity.content != null) {
		data['content'] =  entity.content.map((v) => v.toJson()).toList();
	}
	return data;
}

batchContentFromJson(BatchContent data, Map<String, dynamic> json) {
	if (json['batchNo'] != null) {
		data.batchNo = json['batchNo']?.toString();
	}
	if (json['unit'] != null) {
		data.unit = json['unit']?.toString();
	}
	if (json['quantity'] != null) {
		data.quantity = json['quantity']?.toString();
	}
	if (json['id'] != null) {
		data.id = json['id']?.toInt();
	}
	return data;
}

Map<String, dynamic> batchContentToJson(BatchContent entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['batchNo'] = entity.batchNo;
	data['unit'] = entity.unit;
	data['quantity'] = entity.quantity;
	data['id'] = entity.id;
	return data;
}